package br.com.ozsolucoes.managedbean.negocio.ticket;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

import br.com.ozsolucoes.entity.Ticket;
import br.com.ozsolucoes.managedbean.base.BaseManagedBean;
import br.com.ozsolucoes.util.Constantes;

@ManagedBean
@ViewScoped
public class ListarTicketManagedBean extends BaseManagedBean {

	public ListarTicketManagedBean() {
		super();
	}

	@SuppressWarnings("unchecked")
	@PostConstruct
	public void init() {
		Map<String, Object> requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
		listaTickets = (List<Ticket>) requestMap.get("listaTickets");
	}

	private List<Ticket> listaTickets = new ArrayList<Ticket>();

	private Ticket ticket;
	
	private String descricaoDetalhada;
	

	public String detalharTicket() {
		Map<String, Object> requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
		if (null != ticket) {
			requestMap.put("ticket", ticket);
			requestMap.put("listaTickets", listaTickets);
			return Constantes.DETALHAR_TICKET;
		} else{
			addMessageWarn("Selecione um Ticket!");
			return null;
		}
		
	}

	public String fecharTicket() {
		Map<String, Object> requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
		requestMap.put("ticket", ticket);
		requestMap.put("listaTickets", listaTickets);
		return Constantes.FECHAR_TICKET;
	}

	public String paginaAlterarTicket() {
		Map<String, Object> requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
		requestMap.put("ticket", ticket);
		requestMap.put("listaTickets", listaTickets);
		return Constantes.ALTERAR_TICKET;
	}

	public String paginaExcluirTicket() {
		Map<String, Object> requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
		requestMap.put("ticket", ticket);
		requestMap.put("listaTickets", listaTickets);
		return Constantes.EXCLUIR_TICKET;
	}

	public List<Ticket> getListaTickets() {
		return listaTickets;
	}

	public void setListaTickets(List<Ticket> listaTickets) {
		this.listaTickets = listaTickets;
	}

	public Ticket getTicket() {
		return ticket;
	}

	public void setTicket(Ticket ticket) {
		this.ticket = ticket;
	}

	public String getDescricaoDetalhada() {
		return descricaoDetalhada;
	}

	public void setDescricaoDetalhada(String descricaoDetalhada) {
		this.descricaoDetalhada = descricaoDetalhada;
	}

}
